package org.example.mpdemo1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.mpdemo1.entity.Reservation;

import java.util.List;

@Mapper
public interface ReservationMapper extends BaseMapper<Reservation>{

    @Insert("insert into reservation (user_id, instrument_id, start_time, end_time, create_time, status) values (#{userId}, #{instrumentId}, #{startTime}, #{endTime}, #{createTime}, #{status})")
    public void insertReservation(Reservation reservation);

    @Insert("update reservation set status = #{status} where id = #{id}")
    public void updateStatus(@Param("id") int id, @Param("status") int status);

    @Select("select * from reservation where id = #{id}")
    public List<Reservation> selectById(int id);

    @Select("select * from reservation where user_id = #{userId}")
    public List<Reservation> selectByUserId(int userId);

    @Select("select * from reservation where instrument_id = #{instrumentId}")
    public List<Reservation> selectByInstrumentId(int instrumentId);

    @Select("select * from reservation where instrument_id = #{instrumentId} and status = #{status}")
    public List<Reservation> selectByInstrumentIdAndStatus(@Param("instrumentId") int instrumentId, @Param("status") int status);

    @Select("SELECT * FROM reservation")
    public List<Reservation> selectAll();

    @Delete("delete from reservation where id = #{id}")
    public void deleteById(int id);


}
